package com.bhatni.messageprocessor.macro;

import com.bhatni.messageprocessor.Message;
import com.bhatni.messageprocessor.macro.BaseMacro;
import java.util.Properties;

/**
 * Gets Macro value from the message properties.
 */
public class MessageProperty extends BaseMacro {

    private String defaultValue;

    @Override
    public void setValue(String value) {
        defaultValue = value;
    }

    @Override
    public String getResolvedValue(Message in) {
        Object resolvedValue = in.getHeader().get(getName());
        if (resolvedValue == null) {
            resolvedValue = defaultValue;
        }

        return resolvedValue.toString();
    }

}
